﻿using System;
using System.Data;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using EasyLibrary.AR;
using EasyLibrary.AR.Classes;

namespace EasyFrota_Mobile
{
    public partial class _Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            var u = new Utilizador();
           DataSet myDataSet;
           myDataSet= u.Login(UserName.Text, Password.Text, Request.Browser.Version, Request.Browser.Type, Request.ServerVariables);

        if(myDataSet==null)
        {
                     Response.Redirect("Default.aspx", true);
        }
           if (myDataSet.Tables[0].Rows[0][0].ToString().Length > 0)
           {
               Session["logged_in"] = "yes";
               Session["IDUtilizadores"] = myDataSet.Tables[0].Rows[0][0].ToString();
               Session["User"] = UserName.Text;
                   //Response.Write("Welcome.aspx");
               Response.Redirect("Welcome.aspx",true);

           } 
        }
    }
}